{% include './java.header.j2' %}

package {{ table.mark.package }}.{{ table.mark.business_name }};

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.ToString;

{%- for import in table.derived.java.imports %}
import {{ import }};
{%- endfor %}

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@TableName("{{ table.sql.name }}")
public class {{ table.derived.naming.class_name }} {
{%- for column_name, column in columns.items() %}
    {%- if column.sql.auto_increment %}
    @TableId(value = "{{ column.sql.name }}", type = IdType.AUTO)
    {%- endif %}
    {%- if column.derived.java.type in ['LocalDate', 'LocalDateTime'] %}
    @JsonFormat(pattern = "{{ column.derived.java.datetime_format }}")
    {%- endif %}
    {%- if column.naming.field_name == 'createdAt' %}
    @TableField(fill = FieldFill.INSERT)
    {%- endif %}
    {%- if column.naming.field_name == 'updatedAt' %}
    @TableField(fill = FieldFill.INSERT_UPDATE)
    {%- endif %}
    private {{ column.derived.java.type }} {{ column.naming.field_name }}{% if column.derived.java.default_value %} = {{ column.derived.java.default_value }}{% endif %};
{%- endfor %}
}